package com.zelin.rabbit.Test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class TestRabbitMQ {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //1,发送direct消息
    @Test
    public void sendDirectMessage(){
        rabbitTemplate.convertAndSend("fruits-banana","正在使用direct方式发送消息！");

    }

    //2.发送fanout消息(分裂类型)
    @Test
    public void sendFanoutMessage(){
        rabbitTemplate.convertAndSend("zelin-school","","正在使用fanout发送消息！");
    }

    //3.演示主题模式的消息发送
    //3.1发送goods.#这种类型的消息
    @Test
    public void testSendMessage01(){
        rabbitTemplate.convertAndSend("fruits","goods.ccc.ggg","发送goods.#类型的消息！");
    }
    //3.2发送#.log这种类型的消息
    @Test
    public void testSendMessage02(){
        rabbitTemplate.convertAndSend("fruits","qqq.bbb.log","发送#.log类型的消息！");
    }
    //3.3发送goods.log这种类型的消息
    @Test
    public void testSendMessage03(){
        rabbitTemplate.convertAndSend("fruits","goods.log","发送goods.log类型的消息！");
    }


}
